  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>fetch</title>
  </head>
  <body>
    <input type="file" name="photos" id="fileInput" >
    <img src="" id="myImg" alt="">
    <div onclick="upload()">上传图片</div>
  </body>
  <script>
    function upload() {
      const file = document.querySelector('#fileInput').files
      const _file = Array.prototype.slice.call(file, 0)
      console.log(file)
      let formData = new FormData()
      _file.forEach(item => {
        formData.append('file', item)
      })
      fetch('https://canpointtest.com/frontEnd/ossApi/upload-oss-files?file&folder=npm', {
        method: 'POST',
        body: formData,
      }).then(response => {
         response.json().then(data => {
           console.log(data)
           document.querySelector('#myImg').src = data.data[0].url
          })
      })
    }
  </script>
  </html>